/**
 *
 */
package com.googlecode.bip.dao.deprecated;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;
import javax.naming.NamingException;

//import com.googlecode.bip.dao.BipDAO;
//import com.googlecode.bip.dao.utils.DBHelper;
import com.googlecode.bip.dao.utils.Listable;
import com.googlecode.bip.entity.IUserValue;
import com.googlecode.bip.entity.UserValue;

/**
 *
 * @author Claude CHOISNET
 */
@Deprecated
public class UserValueDAO
//    extends BipDAO
        implements Listable<IUserValue>
{
    private static final long serialVersionUID = 1L;

    /**
     * Create a new UserValueDAO
     */
    public UserValueDAO()
    {
    }

    @Override
    public List<IUserValue> getList( final String sql )
        throws SQLException, NamingException
    {
//        return DBHelper.getList( this, getDataSource(), sql );
        return null;
    }

    @Override
    public IUserValue newInstance( ResultSet resultSet ) throws SQLException
    {
        return new UserValue().set( resultSet );
    }

    /**
     * Returns all categories with value for iduser in range.
     * @param iduser
     * @param dateFrom
     * @param dateTo
     * @return List of idcategory with value for iduser in range.
     * @throws SQLException
     * @throws NamingException
     *
    public List<Integer> getCategoriesList(
            final int       iduser,
            final Timestamp dateFrom,
            final Timestamp dateTo
            )
        throws SQLException, NamingException
    {
        String sql = "SELECT * FROM `uservalueview` WHERE `iduser`='"
            + iduser
            + "' AND `userdate` BETWEEN '"
            + dateFrom
            + "' AND '"
            + dateTo
            + "'  GROUP BY `idcategory`";

        List<UserValue>     luv = getList( sql );
        ArrayList<Integer>  li  = new ArrayList<Integer>();

        for( IUserValue uv : luv ) {
            li.add( uv.getIdcategory() );
            }

        return li;
    }*/

    /**
     *
     * @param idcategory
     * @param iduser
     * @param dateFrom
     * @param dateTo
     * @return
     * @throws SQLException
     * @throws NamingException
     */
    public List<IUserValue> getUserValueList(
            final int       idcategory,
            final int       iduser,
            final Timestamp dateFrom,
            final Timestamp dateTo
            )
        throws SQLException, NamingException
    {
        String sql = "SELECT * FROM `olduservalueview` WHERE `idcategory`='"
            + idcategory
            + "' AND `iduser`='"
            + iduser
            + "' AND `userdate` BETWEEN '"
            + dateFrom
            + "' AND '"
            + dateTo
            + "' ORDER BY `userdate`";

        return getList( sql );
    }
}
